import router from '@system.router';

export default {
    data: {
        status: [
            "off",
            "off",
            "off",
            "off",
            "off"
        ],
        tab: [
            "全部",
            "待付款",
            "待发货",
            "待收货",
            "待评价"
        ],
        current_tab: 0,
        lists: []
    },
    onInit() {
        this.fetch(this.current_tab);
    },
    goBack() {
        router.back();
    },
    fetch(tab) {
        this.status.splice(this.current_tab, 1, "off");
        this.status.splice(tab, 1, "on");
        this.current_tab = tab;
        let orders = [
            [
                "common/images/order/order1.jpg"
            ],
            [

            ],
            [

            ],
            [
                "common/images/order/order2.jpg"
            ],
            [
                "common/images/order/order3.jpg"
            ]
        ]
        this.lists = [];
        switch (tab) {
            case 0: {
                for (let i = 0; i < 5; ++i) {
                    for (let j = 0; j < orders[i].length; ++j)
                        this.lists.push(orders[i][j])
                }
                break;
            }
            default: {
                for (let i = 0; i < orders[tab - 1].length; ++i)
                     this.lists.push(orders[tab - 1][i]);
            }
        }
    }
}
